package server

import (
	"server/base"
	"server/common/models/message"
	"server/pkg/cron/constant"
	"server/pkg/log"
	"server/pkg/nsq"
	"time"
)

type TestUserMessage struct {
	constant.CornRegisterServiceParamBase
}

func (t *TestUserMessage) GetCorn() string {
	return "*/1 * * * *"
}

func (t *TestUserMessage) Run() {
	msg := message.UserMessage{
		From:       1,
		To:         2,
		Type:       "text",
		Content:    "test",
		Status:     "unread",
		CreateTime: time.Now().Unix(),
		UpdateTime: time.Now().Unix(),
	}
	err := base.NsqClient.PushMessageToNsq(nsq.NsqMessage{
		Topic:   nsq.TOPIC_USER_MESSAGE,
		Message: msg.ToByte(),
	})
	if err != nil {
		log.Error("cron", err, "cron test user message error")
	}
}
